package com.ruoyi.framework.mqtt.handler;

import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.stereotype.Component;

/**
 * @author Taney
 */
@Component
public class ItemTestCountHandler extends AbstractHandler {

    public static final String TOPIC = "/event/itemTestCount";

    @Override
    public void handleMessage(Message message, String topic, String msg) throws MessagingException {
        if (matches(TOPIC, topic)) {
            ClientInfo clientInfo = getClientInfo(topic);
            String product = clientInfo.getProduct();
            String deviceId = clientInfo.getDeviceId();
            logger.debug("设备[{}-{}]今日检测项目数量为【{}】", product, deviceId, msg);
            if (msg != null) {
                //更新
                reStatistics(deviceId, ITEM_TEST, Integer.valueOf(msg));
            }
        }
    }
}
